package com.b2j.base;
import static  com.b2j.base.Token.*;
import static  com.b2j.base.TokenGroup.*;
import com.b2j.base.Lexema;

%%

%class Lexer
%type Lexema
%caseless 
%ignorecase

L = [a-zA-Z_]
D = [0-9]
WHITE = [ \t\n\r]

%{
	public String lexema;
%}
%%

{WHITE} {/* ignore */}
"==" 	{return new Lexema(EQUAL, yychar, yyline, yytext(), OPERAND);}
"!=" 	{return new Lexema(NOTEQUAL, yychar, yyline, yytext(), OPERAND);}
">" 	{return new Lexema(GTHAN, yychar, yyline, yytext(), OPERAND);}
"<" 	{return new Lexema(LTHAN, yychar, yyline, yytext(), OPERAND);}
">="    {return new Lexema(GTHANOREQ, yychar, yyline, yytext(), OPERAND);}
"<="    {return new Lexema(LTHANOREQ, yychar, yyline, yytext(), OPERAND);}
"&&" 	{return new Lexema(AND, yychar, yyline, yytext(), OPERAND);}
"||" 	{return new Lexema(OR, yychar, yyline, yytext(), OPERAND);}
"=" 	{return new Lexema(ASSIGN, yychar, yyline, yytext(), OPERAND);}
"+"	 	{return new Lexema(PLUS, yychar, yyline, yytext(), OPERAND);}
"*" 	{return new Lexema(MUL, yychar, yyline, yytext(), OPERAND);}
"-" 	{return new Lexema(MINUS, yychar, yyline, yytext(), OPERAND);}
"/" 	{return new Lexema(DIV, yychar, yyline, yytext(), OPERAND);}
"PROGRAM" {return new Lexema(PROGRAM, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"PROCESS" {return new Lexema(PROCESS, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"IMPORT"  {return new Lexema(IMPORT, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"FUNCTION" 	{return new Lexema(FUNCTION, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"CONST"     {return new Lexema(CONST, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"GLOBAL"    {return new Lexema(GLOBAL, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"LOCAL"     {return new Lexema(LOCAL, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"PUBLIC"    {return new Lexema(PUBLIC, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"PRIVATE"   {return new Lexema(PRIVATE, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"BEGIN"     {return new Lexema(BEGIN, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"END"       {return new Lexema(END, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"INT"    	{return new Lexema(INT, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"FLOAT"     {return new Lexema(FLOAT, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"STRING"    {return new Lexema(STRING, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"IF" 	{return new Lexema(IF, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"ELSE" 	{return new Lexema(ELSE, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"ELSEIF" 	{return new Lexema(ELSEIF, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"SWITCH" 	{return new Lexema(SWITCH, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"CASE" 		{return new Lexema(CASE, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"DEFAULT"   {return new Lexema(DEFAULT, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"BREAK"		{return new Lexema(BREAK, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"CONTINUE"  {return new Lexema(CONTINUE, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"WHILE" 	{return new Lexema(WHILE, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"REPEAT" 	{return new Lexema(REPEAT, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"UNTIL" 	{return new Lexema(UNTIL, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"FROM" 		{return new Lexema(FROM, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"TO" 		{return new Lexema(TO, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"STEP" 		{return new Lexema(STEP, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
"("  		{return new Lexema(OPARENT, yychar, yyline, yytext(), LANGUAGE_COMPONENT);}
")"  		{return new Lexema(CPARENT, yychar, yyline, yytext(), DELIMITER);}
":"     {return new Lexema(COLON, yychar, yyline, yytext(), DELIMITER);}
";"     {return new Lexema(SEMICOLON, yychar, yyline, yytext(), DELIMITER);}
","     {return new Lexema(COMMA, yychar, yyline, yytext(), DELIMITER);}
{L}({L}|{D})* {return new Lexema(ID, yychar, yyline, yytext(), IDENTIFICATOR);}
[\-|\+]*{D}+ 	{return new Lexema(LINT, yychar, yyline, yytext(), VALUE);}
\".*\" 				{return new Lexema(LSTRING, yychar, yyline, yytext(), VALUE);}
\/\/.*      {return new Lexema(COMMENTS, yychar, yyline, yytext(), OTHER);}
. 					{return new Lexema(ERROR, yychar, yyline, yytext(), OTHER);}